//当前模块：API进行统一管理
import requests from "./request.js";
import mockRequests from "./mockRequest.js"
//   三级联动接口
//  /api/product/getBaseCategoryList   get请求  无参数
export const reqCategoryList = ()=>{
    //发请求  axios发请求返回结果Promise对象
    return requests({url:'/product/getBaseCategoryList',method:'get'})
    

}

//获取banner（Home首页大轮播图）
export const reqGetBannerList = ()=>mockRequests({ url: '/banner', method: 'get' });

//获取floor数据
export const reqFloorList = ()=>mockRequests.get('/floor');

//获取搜索模块的数据  地址  /api/list  post
export const reqGetSearchInfo = (params)=>{
  return requests ({url:'/list',method:'post',data:params})
}

//获取详情页面的数据 地址  /api/item/{ skuId }   get
export const reqGoodsInfo = (skuId)=>{
  return requests ({url:`/item/${skuId}`,method:'get'})
}

//添加到购物车（或者更新产品数量） 地址 /api/cart/addToCart/{ skuId }/{ skuNum }  post
export const reqAddOrUpdateShopCart = (skuId,skuNum) =>{
  return requests ({url:`/cart/addToCart/${skuId}/${skuNum}`, method:'post'})
}

//获取购物车列表  地址 /api/cart/cartList   get
export const reqCarList =() => {
  return requests ({url:"/cart/cartList",method:'get'})
}

//删除购物车产品 地址 /api/cart/deleteCart/{skuId}  delete
export const reqDeleteCartById = (skuId)=>{
  return requests({url:`/cart/deleteCart/${skuId}`,method:'delete'});
}

//修改商品的选中状态 地址 /api/cart/checkCart/{skuId}/{isChecked}   get
export const reqUpdateCheckedById = (skuId,isChecked)=>{
  return requests({url:`/cart/checkCart/${skuId}/${isChecked}`,method:'get'})
}
